package com.xiaoma.pattern.proxy.jdk;

import java.lang.reflect.Proxy;

/**
 * @author maj
 * @Description
 * @date 2020-09-27 22:36
 */
public class JdkDynamicProxy {

    public static void main(String[] args) throws Exception {
        //生成$Proxy0的class文件
        System.getProperties().put("sun.misc.ProxyGenerator.saveGeneratedFiles", "true");
//    System.getProperties().put("jdk.proxy.ProxyGenerator.saveGeneratedFiles", "true");
        IHello iHello = (IHello) Proxy.newProxyInstance(IHello.class.getClassLoader(),
                new Class[]{IHello.class},
                new HWInvocationHandler(new Hello()));

        iHello.sayHello();
    }
}
